from rest_framework import serializers

from splits.models import Spit


# from user.models import User


# class UserSerializer(serializers.ModelSerializer):
#     userid = serializers.IntegerField(label='id')
#     class Meta:
#         model = User
#         fields = ('userid', 'nickname', 'avatar',)


class SpitSerializer(serializers.ModelSerializer):
    '''吐槽序列化器类'''
    userid = serializers.IntegerField(label='id', allow_null=True, required=False)
    nickname = serializers.CharField(allow_null=True, label='昵称', max_length=100, required=False)
    avatar = serializers.CharField(allow_null=True, label='用户头像', max_length=500, required=False)
    collected = serializers.BooleanField(default=False, )
    hasthumbup = serializers.BooleanField(default=False)
    state = serializers.IntegerField(label='数字')
    parent = serializers.IntegerField(label='父级id', allow_null=True)

    class Meta:
        model = Spit
        fields = '__all__'
